var twoSum = function (nums, target) {
  if (nums.length === 0) {
    return;
  }

  let map = new Map();

  for (let i = 0; i < nums.length; i++) {
    const rest = target - nums[i];
    if (map.has(rest)) {
      return [map.get(rest), i];
    }
    map.set(nums[i], i);
  }
};
